<?php
namespace app\plus\controller;

use think\Controller;

class CategoryController extends Controller
{
    /**
     * 级联取商品类目
     */
    public function ajaxGoodsCate(){
        $id = $this->request->param('id/d',0);
        $cache = cache('goods_category');
        $catlist = [];
        foreach ($cache as $k=>$v){
            if($v['pid']==$id){
                $tree['id'] = $v['cid'];
                $tree['value'] = $v['cat_name'];
                $tree['parent'] = "pid";
                $tree['isleaf'] = "true";
                if($v['is_son']){
                    $tree['isleaf'] = "false";
                }
                $catlist[]=$tree;
            }
        }
        $data['code'] = 200;
        $data['data'] = $catlist;
        return json($data);
    }

}
